<template>
  <Main>
    <el-button type="primary" size="small" @click="add()" icon="el-icon-plus">上传新版本</el-button>
    <el-table
      :data="tableData"
      style="width: 100%"
      row-key="kid"
      default-expand-all
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column fixed prop="file_name" label="文件名称" ></el-table-column>
      <el-table-column prop="type" label="类型" ></el-table-column>
      <el-table-column prop="version" label="app版本" ></el-table-column>
      <el-table-column prop="statuz" label="状态" ></el-table-column>
       <el-table-column fixed="right" label="操作" width="300px">
        <template slot-scope="scope">
          <el-button type="primary" size="small" @click="edit(scope.row.kid)">
            <i class="el-icon-edit"></i>
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <Add ref="Add" @refresh="fetch"></Add>
    <Edit ref="Edit" @refresh="fetch"></Edit>
  </Main>
</template>

<script>
import Main from "@/components/basic-container/main";
import { baseUrl } from "@/config/env";
import Add from "./add";
import Edit from "./edit";

const urls = {
  delete: baseUrl + "/zweixin/sys/auth/delete",
  list: baseUrl + "/zweixin/app/list"
};
export default {
  methods: {
    add: function() {
      this.$refs.Add.show();
    },
    edit: function(kid) {
      this.$refs.Edit.show(kid);
    },
    fetch() {
      axios.get(urls.list, { params: this.formInline }).then(res => {
        this.tableData = res.data.result;
      });
    }
  },
  mounted() {
    this.fetch();
  },
  data() {
    return {
      formInline: {
        name: null,
        code: null
      },
      tableData: []
    };
  },
  components: {
    Add,
    Edit,
    Main
  }
};
</script>